<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/static/css/reset.css" />
    <link rel="stylesheet" type="text/css" href="/static/css/detail.css" />
    <script type="text/javascript" src="/static/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/static/js/myfunc.js"></script>
    <style>
        table {
            border-collapse: collapse;
            empty-cells: show;
            border-spacing: 0;
            border: 1px solid #ccc;
        }

        th,
        td {
            padding: 4px 15px;
            margin: 0;
            vertical-align: top;
            border: 1px solid #ccc;
            max-width: 340px;
            word-break: break-word;
        }

        th {
            font-weight: bold;
            background-color: #eee;
            text-align: left;
        }
    </style>
</head>

<body>
    <div class="header inner_c">
        <h1 class="fl"><a href="/" target="_blank" title="数据管理系统" alt="数据管理系统">数据管理系统</a></h1>
        <form action="" accept-charset="utf-8" class="search" id="dw__search" method="get"
            role="search">
            <div class="soso fl">
                <div class="kuang_w fl">
                    <input type="text" id="qsearch_in" accesskey="f" name="q" title="[F]" class="kuang"
                        placeholder="搜索本表">
                    <input type="text" style="display: none;">
                </div>
                <div class="sousuo_w fl">
                    <input type="button" class="sousuo" id="submit_ym">
                </div>
            </div>
        </form>
    </div>
    <div class="h10 cl"></div>

    <div class="wai">
        <div class="main">
            <!-- 目录 -->
            <div class="main_l fl" id="menu">
            </div>
            <div class="nei">
                <div class="main_m fl">
                    <div class="main_m_h" id="mbx">
                        <a href="/">首页</a>&nbsp;>&nbsp;<a href="/">元数据</a><span></span>
                    </div>
                    <div id="data_box">

                    </div>
                </div>

                <div class="main_r fl">
                    <div class="hot">相关热搜词</div>
                    <ul class="lb1">
                    </ul>
                    <div class="hot">相关文章</div>
                    <ul class="lb2">
                    </ul>
                </div>
            </div>
        </div>
    </div>


    <!-- 底部的版权信息 -->
    <div class="footer">
        版权所有：国家材料环境腐蚀平台 京ICP备13025191号 京公网安备11010802015897号
    </div>
    <script type="text/javascript" src="/static/js/edataclass.js"></script>
    <script>
        // 获取url上的 classid & tablename
        var classid = 0;
        var tablename = '';
        var id = 0;
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == "classid") {
                classid = pair[1];
            }
            if (pair[0] == "tablename") {
                tablename = pair[1];
            }
            if (pair[0] == "id") {
                id = pair[1];
            }
        }

        // 无classid 跳转首页
        if (classid == 0) {
            window.location.href = "/";
        }

        if (id == 0) {
            window.history.go(-1);
        }

        makemenu(classid);

        $.ajax({
            type: "get",
            url: '/ajax/edata/getedata',
            data: {
                "classid": classid,
                "id": id
            },
            dataType: "json",
            success: function (data) {
                if (data.success == true) {
                    edata = data.data;
                    tableData = edata.tableData;
                    // console.log(edata);
                    var data_str = "";
                    var data_img = "";
                    data_str += "<h2>" + tableData.title + "</h2>";
                    data_str += "<p><span>发布日期：" + formatDate(tableData.newstime) + "</span>";
                    data_str += "<span>浏览次数:"+tableData.onclick+"</span>";
                    data_str += "</p>";
                    data_str += '<div class="biaoge"><table class="table table-bordered table-striped">';
                    data_str += '<thead><tr><th>项目</th><th>数据</th></tr></thead>';
                    data_str += '<tbody>';
                    data_str += '<tr>';
                    data_str += '<td><div align="left">所属数据表</div></td>';
                    data_str += '<td><div class="col-md-4">'+edata.classname+'</div></td>';
                    data_str += '</tr>';
                    // $.each(tableData, function(key, value){
                    //     data_str += '<tr>';
                    //     data_str += '<td><div align="left">'+key+'</div></td>';
                    //     data_str += '<td><div class="col-md-4">'+value+'</div></td>';
                    //     data_str += '</tr>';
                    // });
                    edata.columnList.forEach(col => {
                        // console.log(col.columnNameCN);
                        // console.log(col.columnNameEN);
                        // console.log(tableData[col.columnNameEN]);
                        if (col.columnNameEN=="new_way") {
                            let new_way = tableData[col.columnNameEN];
                            let picInfo = new_way.split("###");                            
                            picInfo.forEach(pic => {
                                data_img += '<img src="/data/new_way/01050109/'+pic+'" style="max-width:500px;">';
                            });
                        }
                        data_str += '<tr>';
                        data_str += '<td><div align="left">'+col.columnNameCN+'</div></td>';
                        data_str += '<td><div class="col-md-4">'+tableData[col.columnNameEN]+'</div></td>';
                        data_str += '</tr>';
                        
                    });
                    
                    data_str += '</tbody></table>';
                    data_str += data_img;
                    data_str += '</div>';
                    $("#data_box").append(data_str);
                    var mbx_str2 = "&nbsp;>&nbsp;" + tableData.title;
                    $("#mbx").append(mbx_str2);
                } else {
                    $("#data_box").append("<h2>"+data.msg+"</h2>");
                }
            },
            error:function(e){
                $("#data_box").append("<h2>数据查询失败</h2>");
            }
        });

        // 搜索按钮
        $("#submit_ym").on("click", function(){
            gosubmit()
        });

        // input框绑定回车键
	    $('#qsearch_in').bind('keydown',function(event){
            if(event.keyCode == "13")
            {
                gosubmit()
            }
        });

        // 执行跳转
        function gosubmit() {
            var newq = $("#qsearch_in").val();
            self.location.href = '/datalist.html?classid=' + classid + '&q='+newq;
        }
    </script>
</body>

</html>

